personal_center_normal_toGetRightProducts = function (info) {
    info.personal_center_loopTotalTimes++;
    if (info.personal_center_loopTotalTimes > info.personal_center_loopTotalTimes_max) {
        info.personal_center_hasFindRightProduct = false;
        logd("move 35 times, back");
        return;
    }

    try {
        console.time("1");
        // get love count node info
        var loveNodeInfos = clz("android.widget.TextView").depth(20)
            .drawingOrder(1).index(1).getNodeInfo(info.personal_center_showProductListWaitTime);
        var time = console.timeEnd("1");
        if (time / 1000 > 4.8) {
            logw("pls check your network");
            personal_center_normal_toGetRightProducts_error(info);
            return;
        }
    } catch (e) {
        loge("find like node error {}", e);
        personal_center_normal_toGetRightProducts_error(info);
        return;
    }

    try {
        // love button maybe not show
        if (loveNodeInfos != null) {
            var index = 0;
            if (info.personal_center_topIsExist) {
                logd("topIsExist : {}", info.personal_center_topIsExist);
                index = 1;
            }
            var normal_loveButtonInfo = null;
            for (var i = index; i < loveNodeInfos.length; i++) {
                var value = loveNodeInfos[i].text;
                logd(" value {}", value)
                // 新文一般不能点击 【赞】不能点击
                if (value != null && !isNaN(value)
                    && parseInt(value) > global_newContentLoveCount
                    && !loveNodeInfos[i].previousSiblings()[0].selected) {
                    logi("click, like count : {}", parseInt(value));
                    normal_loveButtonInfo = loveNodeInfos[i];
                    break;
                }
            }

            if (normal_loveButtonInfo != null) {
                // 查找父元素，进行点击
                var parentNode = global_getParentNodeByChildNode(normal_loveButtonInfo, 2);
                if (parentNode != null) {
                    var clickFlag = parentNode.click();
                    if (clickFlag) {
                        logd("click success");
                    } else {
                        logi("click error")
                    }
                } else {
                    sleep(1000);
                    logd("not find like button parent, need to move");
                    moveToScreenHeightHalf(screenHeight / 5 * 3);
                    personal_center_normal_toGetRightProducts(info);
                }
            } else {
                sleep(1000);
                logd("has no right love button, need to move")
                moveToScreenHeightHalf(screenHeight / 5 * 3);
                personal_center_normal_toGetRightProducts(info);
            }
        } else {
            sleep(1000);
            logd("has no love button, need to move");
            moveToScreenHeightHalf(screenHeight / 5 * 3);
            personal_center_normal_toGetRightProducts(info);
        }
    } catch (e) {
        info.personal_center_hasFindRightProduct = false;
        loge("not find right button to click : {}", e);
    }
};


/**
 * get parent by child node
 *
 * @param childNode
 * @param level
 * @returns {NodeInfo|*|null|null}
 */
global_getParentNodeByChildNode = function (childNode, level) {
    if (childNode == null) {
        return null;
    }
    try {
        var temp = childNode.parent();
        for (var i = 0; i < level - 1; i++) {
            temp = temp.parent();
        }
        return temp;
    } catch (e) {
        loge("global_getParentNodeByChildNode {}", e);
    }
};

personal_center_normal_toGetRightProducts_error = function (info) {
    info.personal_center_hasFindRightProduct = false;
    info.customerHasNotClickedArray.push({
        "id": info.currentAccountName,
        "name": info.currentAccountName
    });
};
